import axios from 'axios'
const CinemaModule = {
    namespaced: true,//开启命名空间
    state() {
        return {
            cinemaList: []
        }
    },
    mutations: {
        changeCinemaList(state, payload) {
            state.cinemaList = payload
        }
    },
    // 异步操作 
    actions: {
        async getCinemaList({ commit }) {
            var res = await axios({
                url: 'https://m.maizuo.com/gateway?cityId=110100&ticketFlag=1&k=4160775',
                headers: {
                    'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.1","e":"17089542072373175589470209","bc":"110100"}',
                    'X-Host': 'mall.film-ticket.cinema.list',
                }
            })
            // console.log(store);
            commit('changeCinemaList', res.data.data.cinemas);
        }
    },
    // getter store的计算属性
    getters: {
        filterCinemaList(state) {
            return (type) => {
                return state.cinemaList.filter(item => item.eTicketFlag === type)
            }
        }
    }
}
export default CinemaModule